#define   _CRT_SECURE_NO_WARNINGS  1
#include<stdio.h>
#define n 4
#define m 4
int main()
{
	int num1[n];
	int num2[m];
	int i;
	for (i = 0; i < n; i++)
		scanf("%d", &num1[i]);
	for (i = 0; i < m; i++)
		scanf("%d", &num2[i]);
	int hash[1000];
	for (i = 0; i < n; i++)
		hash[num1[i]] = 1;
	int v = 0;
	for (i = 0; i < m; i++)
		if (hash[num2[i]] == 1)
		{
			printf("%d ", num2[i]);
			v = 1;
		}
	if (v == 0)
		printf("NO");
	return 0;
}